<?php 
class ModuleCart extends Controller {  
	function fetch() {
		$config   =& $this->locator->get('config');
		$cart     =& $this->locator->get('cart');
		$currency =& $this->locator->get('currency');
		$customer =& $this->locator->get('customer');
		$language =& $this->locator->get('language');
		$url      =& $this->locator->get('url');
		$template =& $this->locator->get('template');
		
		if ($config->get('cart_status')) {	
			$language->load('extension/module/cart.php');
		
			$view = $this->locator->create('template');

			$view->set('tpl', $template);

    		$view->set('heading_title', $language->get('heading_title'));

    		$view->set('text_subtotal', $language->get('text_subtotal'));
			$view->set('text_view_cart', $language->get('text_view_cart'));
			$view->set('view_cart', $url->href('cart'));

			$view->set('text_checkout', $language->get('text_checkout'));
    		$view->set('checkout', $url->href('cart'));

    		$product_data = array();

    		foreach ($cart->getProducts() as $result) {
      			$product_data[] = array(
        			'href'     => $url->href('product', false, array('product_id' => $result['product_id'])),
        			'name'     => $result['name'],
        			'quantity' => $result['quantity']
      			);
    		}
 
    		$view->set('products', $product_data);

    		$view->set('subtotal', $currency->format($cart->getsubTotal()));

    		$view->set('text_empty', $language->get('text_empty'));
    		
    		$view->set('ajaxadd', $config->get('config_ajaxadd'));
	
			return $view->fetch('module/cart.tpl');
		}
  	}
}
?>
